﻿using Common;
using Common.DataModels;

namespace PLC.Domain.Dto
{
    public class DtoDataConfig:BaseDto
    {
       
        /// <summary>
        /// 设备配置id
        /// </summary>
        public long DeviceConfigId { get;  set; }

        /// <summary>
        /// 寄存器位
        /// </summary>
        public string Register { get;  set; }

        /// <summary>
        /// 数据类型
        /// </summary>
        public int DataType { get;  set; }

        /// <summary>
        /// 数据长度
        /// </summary>
        public int DataLength { get;  set; }

        /// <summary>
        /// 数据编码类型
        /// </summary>
        public int? Encoding { get;  set; }
        /// <summary>
        /// 数据组中数据的类型
        /// </summary>
        public int? CodeType { get; set; }
        /// <summary>
        /// 二维码校验的长度
        /// </summary>
        public int? CodeLength { get;  set; }
        /// <summary>
        /// 状态
        /// </summary>
        public int Status { get;  set; }

        /// <summary>
        /// 数据值的描述
        /// </summary>
        public string DataDescription { get;  set; }
        /// <summary>
        /// 值描述的list  要转成json字符串存储
        /// </summary>
        public List<DescriptionItem> DataDescriptionList { get; set; }
        /// <summary>
        /// 配置类型
        /// </summary>
        public int ConfigType { get;  set; }

        /// <summary>
        /// 判断类型(> < = 这些操作)
        /// </summary>
        public int JudgeType { get;  set; }
        /// <summary>
        /// 判断值
        /// </summary>
        public string JudgeValue { get;  set; }
        /// <summary>
        /// 需要触发的操作 只能有一个触发
        /// </summary>
        public int? Trigger { get;  set; }
       
        /// <summary>
        /// 排序值
        /// </summary>
        public int OrderNum { get; set; }
        /// <summary>
        /// 读数据组
        /// </summary>
        public int? ReadGroup { get;  set; }
        /// <summary>
        /// 写数据组
        /// </summary>
        public int? WriteGroup { get;  set; }
       

        public DtoDataConfig SetDataDescriptionList(string dataDescriptionList)
        {
            this.DataDescriptionList = string.IsNullOrWhiteSpace(dataDescriptionList)
                ? new List<DescriptionItem>()
                : JsonHelper.DeserializeObject<List<DescriptionItem>>(dataDescriptionList);
            return this;
        }
    }
/// <summary>
/// 描述的子对象
/// </summary>
    public class DescriptionItem
    {
        public string Description { get; set; }
        public string Value { get; set; }
    }
}
